package com.acme;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.exception.BankExeption;
import com.acme.bankapp.service.bank.BankService;
import com.acme.bankapp.service.bank.CheckingAccount;
import com.acme.bankapp.service.bank.Gender;
import com.acme.bankapp.service.bank.SavingAccount;

public class BankApplication {
	public void modifyBank(Bank bank) {
		try {
			bank.getClient(0).getAcc().withdraw(1000);//balance=204.60
		} catch (BankExeption e) {
			System.err.println("Illegal value: " + e.getAmount());
		}
		try {
			bank.getClient(1).getAcc().withdraw(303);//(overdraft+balance)<300
		} catch (BankExeption e) {
			System.err.println("Invalid query");
		}
	}

	public static void main(String[] args) {
		Bank bank = new Bank();
		BankApplication bapp = new BankApplication();
		BankService bankserv = new BankService();
		
		Client cl1 = new Client("Petrov",Gender.MALE, 45);
		Client cl2 = new Client("Petrova",Gender.FEMALE, 45);
		
		cl1.setAcc(new SavingAccount(204.60));
		cl2.setAcc(new CheckingAccount(200,100));
		
		try {
			bankserv.addClient(bank, cl1);
		} catch (Exception ex) {

		}
		try {
			bankserv.addClient(bank, cl2);
		} catch (Exception ex) {

		}
		bapp.modifyBank(bank);
	}
}
